<?php $this->load->view("common/page_header");?>
	<?php $this->load->view("common/top_banner");?>		
	<?php $this->load->view("common/header");?>
	<?php $this->load->view("common/message");?>
	<?php $is_author = ($story['created_by'] == current_user() ? 1: 0)?>
	<div id="body_main">
		<div class="story_top">
			<div class="story_title"><?php echo $story['title']?></div>
			<div class="story_status">（事项编号：<?php echo 1000000 + $story['id']?>）状态：<span class="orange"><?php echo (!empty($story['expire']) ? '已过期' : '进行中')?></span></div>
			<?php if ($is_author) {?>
			<div class="left bold">
				<a href="<?php echo site_url("story/edit/" . $story['id']);?>">&gt;修改</a>&emsp;
				<a onclick='if(!confirm("你确定要删除此事项?")) return false;' href="<?php echo site_url("story/delete/" . $story['id']);?>">-删除</a>
			</div>
			<?php }?>
			<div class="clear"></div>
		</div>
		<div class="top_border">
			<div class="arrow_up" style="left:90px"></div>
		</div>
		<div id="body_content">
			<div class="left_main">
				<div class="story_info">
					<div class="item"><div class="reward"></div>悬赏：<span class="orange"><?php echo $story['bonus'];?>元</span></div>
					<div class="item">发布对象：<span class="blue"><?php echo $story['is_public'] ? '所有会员' : '验证会员'?></span></div>
					<div class="item"><?php echo (!empty($story['expire']) ? '已过期' : '悬赏期限还有')?><?php echo $story['leave_time']; ?></div>
					<div class="item">发布方：<span class="blue"><a href="/user/story?type=pub&user_id=<?php echo $story['created_by'];?>"><?php echo $story['nickname'];?></a></span><?php if($story['is_vertification']) {?>（身份证验证）<?php }?></div>
					<div class="clear"></div>
				</div>
				<div class="story_content">
					<div class="title">要求：</div>
					<div class="">
						<?php echo nl2br($story['introduction']);?>

					</div>
					<div class="phone_number">联系方式：<?php echo $story['contact'];?></div>
				</div>
				
				<div class="story_sign left" style="margin:15px">
				<?php if(!$is_author) {?>
					<?php if ($is_applied) {?>
						<span>你已经报名</span>
					<?php } else if(empty($story['expire'])){?>
					<a class="enroll" href="<?php echo site_url('story/apply/' . $story['id'])?>">我要报名</a>
					<?php }?>
				<?php }?>
				</div>
				
				<div class="story_actions left" style="margin:25px 0 0 100px">
					<a href="###" class="orange bold" id="share_link">分享</a>
					<a href="###" class="orange bold" id="bookmark_link">收藏</a>
					<a href="###" class="orange bold" id="denounce_link">举报</a>
				</div>
				<div class="clear"></div>
				<div id="denounce">
					<div class="arrow_up">
						<em>◆</em>
						<span>◆</span>
					</div>
					<form id="feedback-form" class="margin_top15 margin_left15" method="post" action="/front/denounce">
						<div class="form_row">
							<label class="input_label"><span class="red">* </span>举报类型：</label>
							<input type="radio" class="input_radio" name="type" value="1"/> 内容违法
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="radio" class="input_radio" name="type" value="2"/> 虚假信息
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="radio" class="input_radio" name="type" value="3"/> 合作欺诈
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="radio" class="input_radio" name="type" value="4"/> 其他(请注明)
						</div>
						<div class="form_row">
							<label class="input_label">具体说明：</label>
							<textarea class="input_textarea" name="content"></textarea>
						</div>
						<div class="form_action">
							<input type="hidden" name="from" value="ajax"></input>
							<input type="hidden" name="target_type" value="story"></input>
							<input type="hidden" name="target_id" value="<?php echo $story['id'];?>"></input>
							<input type="button" value="举报" class="input_button" id="feedback-submit"/>
							
						</div>
						
					</form>
					<div class="clear"></div>
				</div>
				<div id="share_to">
					<div class="arrow_up">
						<em>◆</em>
						<span>◆</span>
					</div>
					<!-- JiaThis Button BEGIN -->
					<div id="jiathis_style_32x32">
						<a class="jiathis_button_qzone"></a>
						<a class="jiathis_button_tsina"></a>
						<a class="jiathis_button_tqq"></a>
						<a class="jiathis_button_renren"></a>
						<a class="jiathis_button_kaixin001"></a>
						<a class="jiathis_button_tianya"></a>
						<a class="jiathis_button_msn"></a>
						<a class="jiathis_button_51"></a>
						<a class="jiathis_button_t163"></a>
						<a class="jiathis_button_baidu"></a>
						<a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
						<a class="jiathis_counter_style"></a>
					</div>
					<script type="text/javascript" src="http://v2.jiathis.com/code/jia.js" charset="utf-8"></script>
					<!-- JiaThis Button END -->
					<div class="clear"></div>
					
				</div>
				<div id="bookmark">
					
				</div>
				<div class="grey" style="margin-left:60px;display:none;" id="success_feedback">
					多谢您的用心付出，我们将跟进您的举报！
				</div>
				
				
				
				<div class="clear"></div>
				<?php if(!empty($pics)) {?>
				<div class="story_images">
					<?php foreach($pics as $pic) {?>
						<a href="/img/uploads/<?php echo $pic['path']?>"><img src="/img/uploads/<?php echo $pic['thumb_path'] ? $pic['thumb_path']: $pic['path'];?>" /></a>
					<?php }?>
				</div>
				<?php }?>
			</div>
			<div class="right_sidebar">
				<?php if(!$is_author && empty($story['expire'])) {?>
				<div class="story_sign">
					<div class="arrow_right"></div>
					<?php if ($is_applied) {?>
						<span>你已经报名</span>
					<?php } else {?>
					<a class="enroll" href="<?php echo site_url('story/apply/' . $story['id'])?>">我要报名</a>
					<?php }?>
					<div class="clear"></div>		
				</div>
				<?php }?>
				<?php if($is_author && !empty($employers)) {?>
				<div class="story_hire_action">
					<span class="bold font14 left" style="margin-top:8px;">雇佣的会员:</span>
					<div class="clear"></div>
				</div>
				<ul class="signed_users">
				<?php foreach($employers as $employer) {?>
				<li class="item">
					<a href="<?php echo site_url("user/show/?user_id=" . $employer['user_id']);?>"><?php echo $employer['nickname'];?></a> 
					<a href="/user/evaluate?user_id=<?php echo $employer['user_id']?>&story_id=<?php echo $story['id'];?>">(评价)</a>
				</li>
				<?php }?>
				</ul>
				<?php }?>
				<?php if (!empty($appliers)) {?>
				<div class="story_hire_action">
					<span class="bold font14 left" style="margin-top:8px;">报名的会员:</span>
					<!--<?php if ($is_author) {?><a class="hire" href="javascript:void(0);">立即雇佣</a> <?php }?>
					--><div class="clear"></div>
				</div>
				<form action="/story/employ" method="get" id="employ-form">
				<input type="hidden" name="story_id" value="<?php echo $story['id'];?>"></input>
				<ul class="signed_users">
					<?php if ($is_author) {?>
						<?php for ($i = 0, $n = count($appliers); $i < $n; $i++) { ?>
						<li class="item">
							<input type="checkbox" name="applier[]" value="<?php echo $appliers[$i]['user_id'];?>"/> <a href="<?php echo site_url("user/show/?user_id=" . $appliers[$i]['user_id']);?>"><?php echo $appliers[$i]['nickname'];?></a> 
						</li>
						<?php } ?>
						<li class="clear"></li>
						<li class="item"><input type="checkbox" id="check-all"/> <span class="blue">全选</span></li>
						<li><a class="hire" href="javascript:void(0);">立即雇佣</a></li>
						</ul>
					<?php } else {?>
						<?php for ($i = 0, $n = count($appliers); $i < $n; $i++) { ?>
						<li class="item">
							 <span class="blue"><a href="/user/show?user_id=<?php echo $appliers[$i]['user_id'];?>"><?php echo $appliers[$i]['nickname'];?></a></span> 
						</li>
						<?php } ?>
						<li class="clear"></li>
						</ul>
					<?php } ?>
				
				</form>
				<?php }?>
			</div>
			<div class="clear"></div>
		</div>

			
		
		<div class="clear"></div>
		
		<?php $this->load->view("common/footer");?>		
		
		<p class="center">Page rendered in {elapsed_time} seconds</p>
	</div>
<script type="text/javascript">
$(document).ready(function(){
	$("#register_button").colorbox({iframe:true, innerWidth:556, innerHeight:320, close:'关闭'});
	$("#login_button").colorbox({iframe:true, innerWidth:390, innerHeight:180, close:'关闭'});
	$(".hire").click(function() {
		$("#employ-form").submit();
	});
	$("#check-all").click(function() {
		$("input[name='applier[]']").attr("checked", true);
	})

	$('#denounce_link').click(function(){
		$('#share_to').hide();
		$('#bookmark').hide();
		$('#denounce').toggle();
		return false;
	});
	$('#bookmark_link').click(function(){
		$('#share_to').hide();
		$('#denounce').hide();
		if ($('#bookmark').css('display') == 'none') {
		$.get("/story/favourite/<?php echo $story['id'];?>",function(data) {
			var link = '<a href="/user/story?type=favourite" class="margin_left15" >&gt;现在查看</a>';
			if (data == 1) {
				msg = "已成功加入收藏夹 ";
			} else if (data == 2) {
				msg = "你已经收藏过该事项";
			} else {
				msg = "你还未登录";
				link = '<a href="/user/login?ref=/story/show/<?php echo $story['id'];?>" class="margin_left15" >&gt;马上登陆</a>';
			}
			html = '<div class="arrow_up">' +
			'<em>◆</em>' + 
			"<span>◆</span>" +
			'</div>' + msg + link;
			$('#bookmark').empty().html(html);
			$('#bookmark').toggle();
		});
		} else {
			$('#bookmark').toggle();
		}
		
		return false;
	});
	$('#share_link').click(function(){
		$('#denounce').hide();
		$('#bookmark').hide();
		$('#share_to').toggle();
		return false;
	});

	$("#feedback-submit").click(function() {
		$.post("/front/denounce", $("#feedback-form").serialize(),function(data){
			if (data == -1) {
				alert("请你先登录");
			} else if(data == 1) {
				$('#denounce').toggle();
				$('#success_feedback').show();
				setTimeout("$('#success_feedback').hide()", 2000);
			} else {
				alert("服务器繁忙，请稍候再试");
			}
		});
	});
});	
</script>
<?php $this->load->view("common/page_footer");?>